﻿<UserControl x:Class="Ewav.LogisticRegression"
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:GadgetSelector="clr-namespace:Ewav.ContextMenu;assembly=Ewav.ContextMenu.Menu"
	xmlns:Common="clr-namespace:CommonLibrary;assembly=CommonLibrary"
	mc:Ignorable="d"
	d:DesignHeight="610" d:DesignWidth="700"
	xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit" 
	xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    DataContext="{Binding Source={StaticResource Locator}, Path=LogisticRegressionViewModel}">

    <Grid x:Name="LayoutRoot" Background="White" MouseRightButtonDown="LayoutRoot_MouseRightButtonDown"
		  MouseLeftButtonDown="LayoutRoot_MouseLeftButtonDown">
        <Grid x:Name="GadgetWindow" Background="White" MinWidth="638" >
			<Grid.RowDefinitions>
        		<RowDefinition Height="50"/>
        		<RowDefinition/>
        	</Grid.RowDefinitions>
        	<Grid.ColumnDefinitions>
        		<ColumnDefinition Width="Auto"/>
        		<ColumnDefinition/>
        	</Grid.ColumnDefinitions>
            <Rectangle x:Name="GWindow" Style="{StaticResource GWindow}" Stroke="{StaticResource WindowBrush}" StrokeThickness="4" Grid.RowSpan="2" Grid.ColumnSpan="2" />
        	<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="13,11,0,0" d:LayoutOverrides="VerticalAlignment, GridBox">
        		<TextBlock x:Name="GName" TextWrapping="Wrap" Text="Logistic Regression" VerticalAlignment="Top" Margin="0,0,26,0" Height="Auto" HorizontalAlignment="Left" Foreground="#FF2B4360" FontSize="21.333"/>

        		<Rectangle x:Name="GHeader" VerticalAlignment="Top" Height="4" Margin="0,2,0,0" StrokeThickness="0" Fill="#FF00B050" />	
        	</StackPanel>
        	<StackPanel Orientation="Horizontal" VerticalAlignment="Top" d:LayoutOverrides="Width" HorizontalAlignment="Right" Margin="180,9,10,0" Grid.Column="1">
        		<Button x:Name="FilterButton" Content="" Template="{StaticResource FilterButton}" Cursor="Hand" Click="FilterButton_Click" Width="24" Height="24" IsEnabled="False" >
        			<Button.Effect>
        				<DropShadowEffect Color="#FFB0B0B0" ShadowDepth="1"/>
        			</Button.Effect>
        		</Button>
        		<Button x:Name="HeaderButton" Content="" Template="{StaticResource HeaderButton}" Cursor="Hand" Click="HeaderButton_Click"  Width="24" Height="24" >
        			<Button.Effect>
        				<DropShadowEffect Color="#FFB0B0B0" ShadowDepth="1"/>
        			</Button.Effect>
        		</Button>
        		<Button x:Name="ResizeButton" Content="" Template="{StaticResource resizebtn}" Cursor="Hand" Click="ResizeButton_Click" Width="24" Height="24" >
        			<Button.Effect>
        				<DropShadowEffect Color="#FFB0B0B0" ShadowDepth="1"/>
        			</Button.Effect>
        		</Button>
        		<Button x:Name="CloseButton" Content="" Template="{StaticResource CloseButton}" Cursor="Hand" Click="CloseButton_Click" Width="24" Height="24" >
        			<Button.Effect>
        				<DropShadowEffect Color="#FFB0B0B0" ShadowDepth="1"/>
        			</Button.Effect>
        		</Button>
        	</StackPanel>
        	<Grid x:Name="GadgetContentGrid" Margin="0,5,0,0" MinHeight="30" Grid.ColumnSpan="2" Grid.Row="1">
        		<toolkit:Expander Margin="0,-45,131,0" VerticalAlignment="Top"  x:Name="gadgetExpander"
        			ExpandDirection="Down" Style="{StaticResource ExpanderStyle2}" Canvas.ZIndex="999" HorizontalAlignment="Right">

        			<toolkit:Expander.Header>
        				<TextBlock Text="Edit Properties" FontFamily="Segoe UI" Cursor="Hand" FontSize="13.333" FontWeight="Normal" Foreground="White"/>
        			</toolkit:Expander.Header>
        			<Grid Background="#FF5C53AC" Margin="0,-2,-89,10" HorizontalAlignment="Right">
        				<StackPanel Margin="4,6,4,0" VerticalAlignment="Top" HorizontalAlignment="Center">
        					<Grid x:Name="grdRegressProperties" Width="Auto" HorizontalAlignment="Center" Margin="10,2" Visibility="Visible">
        						<Grid.RowDefinitions>
        							<RowDefinition Height="20"/>
        							<RowDefinition Height="Auto"/>
        							<RowDefinition Height="25	"/>
        							<RowDefinition Height="Auto"/>
        							<RowDefinition Height="25"/>
        							<RowDefinition Height="Auto"/>
        							<RowDefinition Height="25"/>
        							<RowDefinition Height="Auto"/>
        							<RowDefinition Height="25	"/>
        							<RowDefinition Height="Auto	"/>
        							<RowDefinition Height="30"/>
        							<RowDefinition Height="20"/>
        						</Grid.RowDefinitions>

        						<Grid.ColumnDefinitions>
        							<ColumnDefinition Width="170"/>
        							<ColumnDefinition Width="170"/>
        							<ColumnDefinition Width="170"/>
        						</Grid.ColumnDefinitions>

        						<TextBlock HorizontalAlignment="Left" TextAlignment="Center" Text="Outcome:" Margin="0" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Foreground="White"  />
        						<ComboBox x:Name="cbxFieldOutcome" HorizontalAlignment="Left" SelectedIndex="0" Grid.Row="1" Grid.Column="0" Width="153" SelectionChanged="cbxFieldOutcome_SelectionChanged"/>

        						<TextBlock HorizontalAlignment="Left" TextAlignment="Center" Text="Add Fields:" Margin="0" Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" Foreground="White"  />
        						<ComboBox x:Name="cbxFields" HorizontalAlignment="Left" SelectedIndex="0" Grid.Row="1" Grid.Column="1" MaxWidth="120" Width="120"/>

        						<TextBlock HorizontalAlignment="Left" TextAlignment="Center" Text="Other variables:" Margin="0" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" Foreground="White" />
        						<ListBox x:Name="lbxOtherFields" HorizontalAlignment="Left" SelectedIndex="0" Width="160"  Margin="0,1,0,-9" Grid.Row="3" Grid.Column="1" Grid.RowSpan="6" SelectionMode="Extended" BorderThickness="1"/> <!--SelectionChanged="lbxOtherFields_SelectionChanged"-->
        						<!--SelectionChanged="lbxOtherFields_SelectionChanged"-->

        						<TextBlock HorizontalAlignment="Left" TextAlignment="Center" Text="Weight:" Margin="0" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" Foreground="White" />
        						<ComboBox x:Name="cbxFieldWeight" HorizontalAlignment="Left" SelectedIndex="0" Grid.Row="3" Grid.Column="0" Width="153" />

        						<TextBlock HorizontalAlignment="Left" TextAlignment="Center" Text="Match variable:" Margin="0,5,0,0" Grid.Row="4" Grid.Column="0" Foreground="White" />
        						<ComboBox x:Name="cbxFieldMatch" HorizontalAlignment="Left" SelectedIndex="0" Grid.Row="5" Grid.Column="0" Width="153" />

        						<TextBlock HorizontalAlignment="Left" TextAlignment="Center" Text="Confidence limits:" Margin="0,5,0,0" Grid.Row="6" Grid.Column="0" Foreground="White" />
        						<ComboBox x:Name="cbxConf" HorizontalAlignment="Left" SelectedIndex="0" Grid.Row="7" Grid.Column="0" Width="153" />

        						<CheckBox x:Name="checkboxNoIntercept" HorizontalAlignment="left" Grid.Row="9" Grid.Column="0" Content="No intercept" Padding="4,-1,0,0" FontSize="13.333" Foreground="White" />
        						<CheckBox x:Name="checkboxIncludeMissing" HorizontalAlignment="left" Grid.Row="10" Grid.Column="0" Content="Include missing" Padding="4,-1,0,0" FontSize="13.333" Foreground="White" />

        						<Button x:Name="btnMakeDummy" Content="Make Dummy" Grid.Row="10" HorizontalAlignment="Left" Width="160" Grid.Column="1" Click="btnMakeDummy_Click" Style="{StaticResource btnSec}" Margin="0,0,0,-6" Height="28"/>
        						<!--Click="btnMakeDummy_Click"-->

        						<TextBlock HorizontalAlignment="Left" TextAlignment="Center" Text="Dummy variables:" Margin="0" Grid.Row="0" Grid.Column="2" VerticalAlignment="Center" Foreground="White" />
        						<ListBox x:Name="lbxDummyTerms" HorizontalAlignment="Left" SelectedIndex="0" Width="160"  Margin="0,1,0,0" Grid.Row="1" Grid.Column="2" Grid.RowSpan="4" SelectionMode="Single" BorderThickness="1" />

        						<TextBlock HorizontalAlignment="Left" TextAlignment="Center" Text="Interaction terms:" Margin="1,8,0,0" Grid.Row="5" Grid.Column="2" VerticalAlignment="Bottom" Foreground="White" />
        						<ListBox x:Name="lbxInteractionTerms" HorizontalAlignment="Left" SelectedIndex="0" Width="160"  Margin="0,2,0,-9" Grid.Row="6" Grid.Column="2" Grid.RowSpan="3" SelectionMode="Single" BorderThickness="1"  />

        						<Button x:Name="btnMakeInteractionTerms" Content="Make Interaction" Grid.Row="10" Grid.Column="2" Width="160" HorizontalAlignment="Left" Click="btnMakeInteractionTerms_Click" Style="{StaticResource btnSec}" Margin="0,0,0,-6" Height="28" />
        						<!--Click="btnClearInteractionTerms_Click"-->
        						<Button x:Name="btnRemoveDummy" Content="X" Grid.Column="2" HorizontalAlignment="Right" Margin="0,0,47,0" Width="16" Height="16" Click="btnRemoveDummy_Click" Style="{StaticResource Delete}" ToolTipService.ToolTip="Clear Selected Dummy Variables" Cursor="Hand" VerticalAlignment="Center"/>
        						<Button x:Name="btnRemoveInteraction" Content="X" Grid.Column="2" HorizontalAlignment="Right" Margin="0,0,47,0" Width="16" Height="16" Grid.Row="5" Click="btnRemoveInteraction_Click" Style="{StaticResource Delete}" ToolTipService.ToolTip="Clear Selected Interaction Terms" Cursor="Hand" VerticalAlignment="Bottom"/>
        						<Button x:Name="btnRemoveVariables" Content="X" Grid.Column="1" HorizontalAlignment="Right" Margin="0,0,59,0" Width="16" Height="16" Click="btnRemoveVariables_Click" Style="{StaticResource Delete}" Grid.Row="2" ToolTipService.ToolTip="Clear Selected Variables" Cursor="Hand" VerticalAlignment="Center"/>
        					</Grid>

        					<Button x:Name="btnRun" Content="Run Gadget" Grid.Row="7" Grid.Column="0" Grid.ColumnSpan="2" Margin="10,2,10,10" Cursor="Hand" Click="btnRun_Click" Width="331" HorizontalAlignment="Left" Style="{StaticResource btnSec}" Height="28"/>
        					<Button x:Name="btnReset" Content="Clear All" Grid.Row="7" Grid.Column="0" Grid.ColumnSpan="2" Margin="200,-39,20,10" Cursor="Hand" Click="btnReset_Click" Width="160" HorizontalAlignment="Right" Style="{StaticResource btnSec}" Height="28"/>
        				</StackPanel>
        				<TextBlock HorizontalAlignment="Right" Height="14" Margin="0,0,36,94" TextWrapping="Wrap" Text="(Select 2 variables)" VerticalAlignment="Bottom" Width="139" TextAlignment="Center" FontSize="10.667" Foreground="White"/>

        			</Grid>
        		</toolkit:Expander>

        		<StackPanel x:Name="spContent" Orientation="Vertical" Margin="7,10,11,10">
        			<TextBlock x:Name="txtGadgetDescription" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,3,0,0" MaxWidth="650" Padding="0,0,10,0" />
        			<StackPanel x:Name="pnlStatus" Height="58" MaxHeight="40" Width="Auto" Background="#FFf8d7e2" VerticalAlignment="Top" Margin="5" HorizontalAlignment="Left" Visibility="Collapsed" >
        				<StackPanel x:Name="pnlStatusTop" Height="2" Width="Auto" Background="#FFe4658e"/>
        				<Image x:Name="ErrorIcon" Source="../../Images/error.png" Width="18" Height="18" HorizontalAlignment="Left" Margin="5,1,5,0" VerticalAlignment="Center"/>
        				<TextBlock x:Name="txtStatus" Text="Error: Exception occurred." TextWrapping="Wrap" Margin="30,-15,5,5" HorizontalAlignment="Left" FontWeight="Bold" VerticalAlignment="Center"/> 
        			</StackPanel>
        			<StackPanel x:Name="pnlContent" HorizontalAlignment="Left">
        				<Grid x:Name="grdRegress" MinWidth="600" HorizontalAlignment="Left" Margin="10" Visibility="Collapsed">
        					<Grid.ColumnDefinitions>
        						<ColumnDefinition Width="Auto"/>
        						<ColumnDefinition Width="Auto"/>
        						<ColumnDefinition Width="Auto"/>
        						<ColumnDefinition Width="Auto"/>
        						<ColumnDefinition Width="Auto"/>
        						<ColumnDefinition Width="Auto"/>
        						<ColumnDefinition Width="Auto"/>
        						<ColumnDefinition Width="Auto"/>
        					</Grid.ColumnDefinitions>
        				</Grid>
        				<Grid x:Name="grdStats" HorizontalAlignment="Left" Visibility="Collapsed" Margin="10">
        					<Grid.RowDefinitions>
        						<RowDefinition Height="25"/>
        						<RowDefinition Height="25"/>
        						<RowDefinition Height="25"/>
        						<RowDefinition Height="25"/>
        					</Grid.RowDefinitions>
        					<Grid.ColumnDefinitions>
        						<ColumnDefinition Width="150"/>
        						<ColumnDefinition Width="75"/>
        					</Grid.ColumnDefinitions>
        					<TextBlock x:Name="txtConvergenceLabel" FontWeight="Bold" Margin="2, 2, 2, 2" VerticalAlignment="Center" HorizontalAlignment="Left" Visibility="Visible" Grid.Row="0" Grid.Column="0" Text="Convergence:"/>
        					<TextBlock x:Name="txtIterationsLabel" FontWeight="Bold" Margin="2, 2, 2, 2" VerticalAlignment="Center" HorizontalAlignment="Left" Visibility="Visible" Grid.Row="1" Grid.Column="0"  Text="Iterations:"/>
        					<TextBlock x:Name="txtFinalLogLabel" FontWeight="Bold" Margin="2, 2, 2, 2" VerticalAlignment="Center" HorizontalAlignment="Left" Visibility="Visible" Grid.Row="2" Grid.Column="0"  Text="Final -2*Log-Likelihood:"/>
        					<TextBlock x:Name="txtCasesIncludedLabel" FontWeight="Bold" Margin="2, 2, 2, 2" VerticalAlignment="Center" HorizontalAlignment="Left" Visibility="Visible" Grid.Row="3" Grid.Column="0"  Text="Cases Included:"/>

        					<TextBlock x:Name="txtConvergence" FontWeight="Normal" Margin="2, 2, 2, 2" VerticalAlignment="Center" HorizontalAlignment="Left" Visibility="Visible" Grid.Row="0" Grid.Column="1" Text=""/>
        					<TextBlock x:Name="txtIterations" FontWeight="Normal" Margin="2, 2, 2, 2" VerticalAlignment="Center" HorizontalAlignment="Left" Visibility="Visible" Grid.Row="1" Grid.Column="1" Text=""/>
        					<TextBlock x:Name="txtFinalLog" FontWeight="Normal" Margin="2, 2, 2, 2" VerticalAlignment="Center" HorizontalAlignment="Left" Visibility="Visible" Grid.Row="2" Grid.Column="1" Text=""/>
        					<TextBlock x:Name="txtCasesIncluded" FontWeight="Normal" Margin="2, 2, 2, 2" VerticalAlignment="Center" HorizontalAlignment="Left" Visibility="Visible" Grid.Row="3" Grid.Column="1" Text=""/>
        				</Grid>
        				<Grid x:Name="grdParameters" HorizontalAlignment="Left" Margin="10" Visibility="Collapsed">
        					<Grid.RowDefinitions>
        						<RowDefinition Height="30"/>
        						<RowDefinition Height="30"/>
        						<RowDefinition Height="30"/>
        					</Grid.RowDefinitions>
        					<Grid.ColumnDefinitions>
        						<ColumnDefinition Width="Auto"/>
        						<ColumnDefinition Width="Auto"/>
        						<ColumnDefinition Width="Auto"/>
        						<ColumnDefinition Width="Auto"/>
        					</Grid.ColumnDefinitions>
        					<Rectangle Grid.Row="0" Grid.Column="0" Style="{StaticResource HeaderCell}"/>
        					<Rectangle Grid.Row="0" Grid.Column="1" Style="{StaticResource HeaderCell}"/>
        					<Rectangle Grid.Row="0" Grid.Column="2" Style="{StaticResource HeaderCell}"/>
        					<Rectangle Grid.Row="0" Grid.Column="3" Style="{StaticResource HeaderCell}"/>
        					<Rectangle Grid.Row="0" Grid.Column="4" Style="{StaticResource HeaderCell}"/>
        					<Rectangle Grid.Row="1" Grid.Column="0" Style="{StaticResource DataCell}"/>
        					<Rectangle Grid.Row="1" Grid.Column="1" Style="{StaticResource DataCell}"/>
        					<Rectangle Grid.Row="1" Grid.Column="2" Style="{StaticResource DataCell}"/>
        					<Rectangle Grid.Row="1" Grid.Column="3" Style="{StaticResource DataCell}"/>
        					<Rectangle Grid.Row="1" Grid.Column="4" Style="{StaticResource DataCell}"/>
        					<Rectangle Grid.Row="2" Grid.Column="0" Style="{StaticResource DataCell}"/>
        					<Rectangle Grid.Row="2" Grid.Column="1" Style="{StaticResource DataCell}"/>
        					<Rectangle Grid.Row="2" Grid.Column="2" Style="{StaticResource DataCell}"/>
        					<Rectangle Grid.Row="2" Grid.Column="3" Style="{StaticResource DataCell}"/>
        					<Rectangle Grid.Row="2" Grid.Column="4" Style="{StaticResource DataCell}"/>
        					<Rectangle Grid.Row="3" Grid.Column="0" Style="{StaticResource DataCell}"/>
        					<Rectangle Grid.Row="3" Grid.Column="1" Style="{StaticResource DataCell}"/>
        					<Rectangle Grid.Row="3" Grid.Column="2" Style="{StaticResource DataCell}"/>
        					<Rectangle Grid.Row="3" Grid.Column="3" Style="{StaticResource DataCell}"/>
        					<Rectangle Grid.Row="3" Grid.Column="4" Style="{StaticResource DataCell}"/>

        					<TextBlock Margin="4, 0, 4, 0" Grid.Row="0" Grid.Column="0" Text="Test" Style="{StaticResource HeaderFont}"/>
        					<TextBlock Margin="4, 0, 4, 0" Grid.Row="0" Grid.Column="1" Text="Statistic" Style="{StaticResource HeaderFont}"/>
        					<TextBlock Margin="4, 0, 4, 0" Grid.Row="0" Grid.Column="2" Text="D.F." Style="{StaticResource HeaderFont}"/>
        					<TextBlock Margin="4, 0, 4, 0" Grid.Row="0" Grid.Column="3" Text="P-Value" Style="{StaticResource HeaderFont}"/>

        					<TextBlock Margin="4, 0, 4, 0" Grid.Row="1" Grid.Column="0" Text="Score" Style="{StaticResource HeaderFont}" HorizontalAlignment="Left"/>
        					<TextBlock Margin="4, 0, 4, 0" Grid.Row="2" Grid.Column="0" Text="Likelihood Ratio" Style="{StaticResource HeaderFont}" HorizontalAlignment="Left"/>

        					<TextBlock Margin="4, 0, 4, 0" x:Name="txtScoreStatistic" VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="1" Grid.Column="1" />
        					<TextBlock Margin="4, 0, 4, 0" x:Name="txtScoreDF" VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="1" Grid.Column="2" />
        					<TextBlock Margin="4, 0, 4, 0" x:Name="txtScoreP" VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="1" Grid.Column="3" />

        					<TextBlock Margin="4, 0, 4, 0" x:Name="txtLStatistic" VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="2" Grid.Column="1" />
        					<TextBlock Margin="4, 0, 4, 0" x:Name="txtLDF" VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="2" Grid.Column="2" />
        					<TextBlock Margin="4, 0, 4, 0" x:Name="txtLP" VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="2" Grid.Column="3" />
        				</Grid>
        			</StackPanel>
                    

        		</StackPanel>
        		<Grid x:Name="waitCursor" Background="#36C4C4C4" Height="Auto" Visibility="Collapsed" d:IsLocked="True">
        			<toolkit:BusyIndicator x:Name="BusyIndicator" IsBusy="True" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="100" />
        		</Grid>
        	</Grid>
        </Grid>
    </Grid>
</UserControl>
